use clonefile copy for macvm boxes #459
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Vagrant uses
prlctl clone
to make a copy of the stored box whenup
'ing a VM. On Intel, this can be a linked clone, but on ARM, this is not an option with Apple's MacVMs. As such, Parallels does a full traditional copy of the box files into a new location that is then registered resulting in the requirement of2(box size)
space. Since MacVMs can be quite large (in our case 30-40GB after all our preparation and additional software), this can quickly run a laptop out of space with just a VM or two. (There's other factors here as well, like APFS snapshots if you're running Time Machine which will hold on to space after you've destroyed VMs.)APFS supports the
clonefile(2)
call which creates a copy-on-write clone of the file meaning it's effectively a quick and free operation to fork a copy of a file. Subsequent writes to the clone are where additional bytes begin to be required. In our testing, this has been a huge time and space saver to do a clone copy of the MacVM and register it into Parallels.I believe the best option is for Parallels to natively implement this when calling
prlctl clone
on APFS but considering that's a bigger ask and closed-source, I've created these modifications to the vagrant-parallels plugin to orchestrate it as a workaround until proper support can be added to Parallels.